/*
Not yet supported in code generation: unknown construct
try {
	$fail = False;
} catch (exception $exception) {
	$fail = True;
}

<MIR:Try>
	<attrs>
		<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
		<attr key="phc.line_number"><integer>7</integer></attr>
	</attrs>
	<MIR:Statement_list>
		<MIR:Assign_var>
			<attrs>
				<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
				<attr key="phc.line_number"><integer>8</integer></attr>
			</attrs>
			<MIR:VARIABLE_NAME>
				<attrs>
					<attr key="phc.codegen.st_entry_not_required"><bool>true</bool></attr>
					<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
					<attr key="phc.line_number"><integer>8</integer></attr>
				</attrs>
				<value>fail</value>
			</MIR:VARIABLE_NAME>
			<bool><!-- is_ref -->false</bool>
			<MIR:BOOL>
				<attrs>
					<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
					<attr key="phc.line_number"><integer>8</integer></attr>
				</attrs>
				<value>False</value>
			</MIR:BOOL>
		</MIR:Assign_var>
	</MIR:Statement_list>
	<MIR:Catch_list>
		<MIR:Catch>
			<attrs>
				<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
				<attr key="phc.line_number"><integer>9</integer></attr>
			</attrs>
			<MIR:CLASS_NAME>
				<attrs />
				<value>exception</value>
			</MIR:CLASS_NAME>
			<MIR:VARIABLE_NAME>
				<attrs>
					<attr key="phc.codegen.st_entry_not_required"><bool>true</bool></attr>
				</attrs>
				<value>exception</value>
			</MIR:VARIABLE_NAME>
			<MIR:Statement_list>
				<MIR:Assign_var>
					<attrs>
						<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
						<attr key="phc.line_number"><integer>10</integer></attr>
					</attrs>
					<MIR:VARIABLE_NAME>
						<attrs>
							<attr key="phc.codegen.st_entry_not_required"><bool>true</bool></attr>
							<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
							<attr key="phc.line_number"><integer>10</integer></attr>
						</attrs>
						<value>fail</value>
					</MIR:VARIABLE_NAME>
					<bool><!-- is_ref -->false</bool>
					<MIR:BOOL>
						<attrs>
							<attr key="phc.filename"><string>/home/mdupont/parser/ParserTryCatch.php</string></attr>
							<attr key="phc.line_number"><integer>10</integer></attr>
						</attrs>
						<value>True</value>
					</MIR:BOOL>
				</MIR:Assign_var>
			</MIR:Statement_list>
		</MIR:Catch>
	</MIR:Catch_list>
</MIR:Try>
*/

//Pattern * createPattern_try_catch();


#include "Generate_C_std.h"

class Pattern_try_catch : public Pattern
{
public:
  bool match(Statement* that)
  {
    m_try  = new Wildcard<Try>;
    return that->match (m_try);
  }
  
  void Print(ostream & os, Try * rhs)
  {
    
  }
  
  void Print(ostream & os, Wildcard<Try> * rhs)
  {
    Print(os,rhs->value);
  }
  void generate_code(Generate_C* gen)
  {
    //INST (buf, "return", ret->value->rvalue, ret->value);
    buf << "BEGINMyTry;";
    Print(buf,m_try);
    //compile_statement
    buf << "EndMyTry;";
    
  }

protected:
  Wildcard<Try>* m_try;
};

CREATE(Pattern_try_catch);
